import React, { Component } from 'react'

export default class Like extends Component {
    constructor (){
        super()

        this.state = {
            isLiked:false
        }
    }


    handleLikedClick = ()=>{
        // this.setState({
        //     isLiked : !this.state.isLiked
        // })

        this.setState((preveState,props)=>{
            console.log(preveState,props)
            return {
                isLiked: !preveState.isLiked
            } 
        },()=>{
            console.log(this.state.isLiked)
        })
        
    }


    render() {
        return (
            <div>
                <span onClick = {this.handleLikedClick}>
                {
                    this.state.isLiked ? '喜欢 🌑' : '取消 🌕'
                }
                </span>
            </div>
        )
    }
}
